import { marriageBaseStatusMap, genderBaseMap, idTypeMap, authIdTypeMap, relationshipMap } from './dictionary';

const defaultI18nRender = (key, fallback) => fallback;

export function formatMarriageBaseStatus(id, i18nRender = defaultI18nRender) {
  const item = marriageBaseStatusMap[id];
  if (item) {
    return i18nRender(item.i18nKey, item.name);
  }
  return '';
}

export function formatGenderBase(id, i18nRender = defaultI18nRender) {
  const item = genderBaseMap[id];
  if (item) {
    return i18nRender(item.i18nKey, item.name);
  }
  return '';
}

export function formatIdType(key, i18nRender = defaultI18nRender) {
  const item = idTypeMap[key];
  if (item) {
    return i18nRender(item.i18nKey, item.name);
  }
  return '';
}

export function formatAuthIdType(key, i18nRender = defaultI18nRender) {
  const item = authIdTypeMap[key];
  if (item) {
    return i18nRender(item.i18nKey, item.name);
  }
  return '';
}

export function formatRelationship(id, i18nRender = defaultI18nRender) {
  const item = relationshipMap[id];
  if (item) {
    return i18nRender(item.i18nKey, item.name);
  }
  return '';
}
